package com.sky.dto;

import com.sky.utils.BeanCopierUtils;
import net.sf.cglib.beans.BeanCopier;

public class AbstractObject {
    /**
     * 浅度克隆
     * @param clazz 目标对象
     * @return
     * @throws Exception
     */
    /**
     * 浅度克隆
     * @param clazz 目标对象
     * @return
     * @throws Exception
     */
    public <T> T clone(Class<T> clazz) throws Exception {
        T target = clazz.newInstance();
        BeanCopier copier = BeanCopierUtils.getBeanCopier(this.getClass(), clazz);
        copier.copy(this, target, null);
        return target;
    }
}
